package action_行为型.visitor_pattern_访问者模式;

/**
 * Created with IntelliJ IDEA.
 *
 * @Auther: hihi
 * @Date: 2020/07/09/20:23
 * @Description:
 */
public class Computer implements ComputerPart {

	private ComputerPart[] computerParts;

	public Computer() {
		computerParts = new ComputerPart[] { new Monitor(), new Mouse(), new KeyBoard() };
	}

	/**
	 * 接受
	 *
	 * @param visitor
	 */
	@Override public void accept(ComputerPartVisitor visitor) {
		for (ComputerPart computerPart : computerParts) {
			computerPart.accept(visitor);
		}
		visitor.visit(this);
	}
}
